var timerlen = 5;
var slideAniLen = 350;

var timerID = new Array();
var startTime = new Array();
var obj = new Array();
var endHeight = new Array();
var moving = new Array();
var dir = new Array();

function slidedown(objname)
{
        if(moving[objname])
                return;
        if(document.getElementById(objname).style.display == "visible")
                return; // cannot slide down something that is already visible
        moving[objname] = true;
        dir[objname] = "down";
        startslide(objname);
}

function slideup(objname){
        if(moving[objname])
                return;

        if(document.getElementById(objname).style.display == "hidden")
                return; // cannot slide up something that is already hidden

        moving[objname] = true;
        dir[objname] = "up";
        startslide(objname);
}

function startslide(objname){

        obj[objname] = document.getElementById(objname);
		obj[objname].style.height = '20px';
        endHeight[objname] = parseInt(obj[objname].style.height);
        startTime[objname] = (new Date()).getTime();
		if(timerID)
		{
			if(timerID[objname])
				clearInterval(timerID[objname]);
		}
		else
		{
			timerID = new Array();
			timerID[objname] = true;
		}
        if(dir[objname] == "down")
			obj[objname].style.top = "-30px";
        obj[objname].style.display = "block";
        timerID[objname] = setInterval('slidetick(\'' + objname + '\');',timerlen);
}

function slidetick(objname){
	
		if(typeof(obj[objname]) == "undefined" )
			{endSlide(objname);return;}
        var elapsed = (new Date()).getTime() - startTime[objname];

        if (elapsed > slideAniLen)
                endSlide(objname)
        else {
                var d =Math.round(elapsed / slideAniLen * endHeight[objname]);
                if(dir[objname] == "up")
                    obj[objname].style.top = -d + "px";
				else
                	obj[objname].style.top = (d - endHeight[objname]) + "px";
        }
        return;
}

function endSlide(objname){
		if(timerID)
			if(typeof(timerID[objname]) != "null" )
				clearInterval(timerID[objname]);

        if(dir[objname] == "up")
                obj[objname].style.display = "none";
				
		if(typeof(obj[objname]) != "undefined" )
			obj[objname].style.top = "0px";
			
        delete(moving[objname]);
        //delete(timerID[objname]);
        delete(startTime[objname]);
        delete(endHeight[objname]);
        delete(obj[objname]);
        delete(dir[objname]);
        return;
}